package testMybatis;

import com.chinaunicom.mybatis.model.Answer;

import java.util.Date;
import java.util.concurrent.ExecutorService;

/**
 * Created by houjinxin on 16/9/4.
 */
public class BizUtil {

    public static Answer createAnswer(final int i, final Date date){
        Answer answer = new Answer() {{
            setUserName("houjinxin" + i);
            setContent("fasfsafas");
            setCreateTime(date);
            setAgreeCount(1);
            setAdopt(1);
            setBegincodeUserId(1);
            setDeleteFlag(0);
            setFeedback(1);
            setOppositionCount(12);
            setProblemId(1);
        }};
        return answer;
    }

    public static void stopThreadPool(ExecutorService service) throws InterruptedException {
        //不在接收新的任务
        service.shutdown();
        while (true) {
//            System.out.println("线程池是否shutdown：" + (service.isShutdown() ? "已shutdown":"未shutdown"));
            System.out.println("线程池是否终止：" + (service.isTerminated() ? "已终止":"未终止"));
            if (service.isTerminated()) {
                System.out.println("结束！");
                break;
            }
            Thread.sleep(200);
        }
    }
}
